﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<dbPoll_Application.Models.RegisterModel>" %>

<p><%= Html.ActionLink("Manage Accounts > ", "ManageAccounts", "Account", null, new { @class = "breadcrumb" })%><%= Model.IsNew == true ? "New" : Model.UserName %></p>
<% if (Model.SelectedRole != null)
       {
           using (Html.BeginForm("Account", "Register", FormMethod.Post, new { @id = "registerForm" }))
           { %>
    <% Html.ValidationSummary(true); %>
    <div id="registerContainer">
    <% if (Model.IsEditable == false)
       { %>
       <%= Html.HiddenFor(model => model.UserName)%>
    <% } %>
    <table id="CreateTable">
	    <tr>
	    <td align="right"><label for="UserName">User Name:</label></td>
	    <td><%= (Model.IsEditable == true) ? Html.TextBoxFor(model => model.UserName) : Html.TextBoxFor(model => model.UserName, new { @readonly = true }) %></td>
	    <td><span id="UserNameMessage"><%= Html.ValidationMessageFor(model => model.UserName)%></span></td>
	    </tr>
	    <tr id="EmailRow">
	    <td align="right"><label for="Email">E-mail:</label></td>
	    <td><%= (Model.IsNew == true) ? Html.TextBoxFor(model => model.Email) : Html.TextBoxFor(model => model.Email, new { @readonly = true })%></td>
	    <td><span id="EmailMessage"><%= Html.ValidationMessageFor(model => model.Email)%></span></td>
	    </tr>
	    <% if (Model.SelectedRole == "Poll User")
        {
            foreach (var item in Model.GenericEmails)
            {
                Html.RenderPartial("GenericEmailRow", item);
            }
        } %>
        <%
    if (Model.SelectedRole != "Poll User")
    {%>
	    <tr>
	    <td align="right"><label for="FirstName">First Name:</label></td>
	    <td><%= (Model.IsEditable == true) ? Html.TextBoxFor(model => model.FirstName) : Html.TextBoxFor(model => model.FirstName, new { @readonly = true }) %></td>
	    <td><span><%= Html.ValidationMessageFor(model => model.FirstName)%></span></td>
	    </tr>
	    <tr>
	    <td align="right"><label for="LastName">Last Name:</label></td>
	    <td><%= (Model.IsEditable == true) ? Html.TextBoxFor(model => model.LastName) : Html.TextBoxFor(model => model.LastName, new { @readonly = true }) %></td>
	    <td><span><%= Html.ValidationMessageFor(model => model.LastName)%></span></td>
	    </tr>
        <tr align="right">
        <td><label>Gender:</label></td>
        <td align="left"><label for="Male">Male:</label><%= (Model.IsEditable == true) ? 
                                    Html.RadioButtonFor(model => model.Gender, dbPoll_Application.Models.Gender.Male) :
                                    Html.RadioButtonFor(model => model.Gender, dbPoll_Application.Models.Gender.Male, new { @disabled = true }) %>
        <label for="Female">Female:</label><%= (Model.IsEditable == true) ? 
                                    Html.RadioButtonFor(model => model.Gender, dbPoll_Application.Models.Gender.Female) :
                                    Html.RadioButtonFor(model => model.Gender, dbPoll_Application.Models.Gender.Female, new { @disabled = true }) %></td>
        <td><%= Html.ValidationMessageFor(model => model.Gender)%></td>
        </tr>
	    <tr>
	    <td align="right"><label for="Organisation">Organisation:</label></td>
	    <td><%= (Model.IsEditable == true) ? Html.TextBoxFor(model => model.Organisation) : Html.TextBoxFor(model => model.Organisation, new { @readonly = true }) %></td>
	    <td><span><%= Html.ValidationMessageFor(model => model.Organisation)%></span></td>
	    </tr>
	    <tr>
	    <td align="right"><label for="Position">Position:</label></td>
	    <td><%= (Model.IsEditable == true) ? Html.TextBoxFor(model => model.Position) : Html.TextBoxFor(model => model.Position, new { @readonly = true }) %></td>
	    <td><span><%= Html.ValidationMessageFor(model => model.Position)%></span></td>
	    </tr>
	    <tr>
	    <td align="right"><label for="City">City:</label></td>
	    <td><%= (Model.IsEditable == true) ? Html.TextBoxFor(model => model.City) : Html.TextBoxFor(model => model.City, new { @readonly = true }) %></td>
	    <td><span><%= Html.ValidationMessageFor(model => model.City)%></span></td>
	    </tr>
	    <tr>
	    <td align="right"><label for="Country">Country:</label></td>
	    <td><%= (Model.IsEditable == true) ? Html.TextBoxFor(model => model.Country) : Html.TextBoxFor(model => model.Country, new { @readonly = true }) %></td>
	    <td><span><%= Html.ValidationMessageFor(model => model.Country)%></span></td>
	    </tr>
        <%
    } %>
        <% if (Model.SelectedRole == "Poll User")
           { %>
	    <tr>
	    <td align="right"><label for="IsGeneric">Generic:</label></td>
	    <td><%= (Model.IsEditable == true) ? Html.CheckBoxFor(model => model.IsGeneric) : Html.CheckBoxFor(model => model.IsGeneric, new { @disabled = true }) %></td>
	    <td></td>
	    </tr>
	    <tr>
	    <td align="right"></td>
	    <td><input type="button" value="Add Email" id="AddEmail" style="display:none" /></td>
	    <td></td>
	    </tr>
	    <% } %>
	    <%= Html.HiddenFor(model => model.SelectedRole)%>
	    <%= Html.HiddenFor(model => model.IsEditable) %>
	    <%= Html.HiddenFor(model => model.IsNew) %>
	    <% if (Model.IsNew)
        { %>
	    <tr>
	    <td></td>
	    <td><input type="submit" name="Register" id="Register" value="<%= (Model.IsEditable == true) ? "Register" : "Save" %>" /></td>
	    <td></td>
	    </tr>
	    <% } %>
	    </table>
    </div>
    <%= Html.ValidationSummary(true)%>
    <%  }  %>
       <div id="rightColumn">
       
       <div class="right" id="BulkTool" style="display:none">
           <ul class="rightColumnList" id="Ul1">
               <li class="rightColumnListHeading"><h2>bulk insert tool</h2></li>
               <li class="rightColumnListItem">Copy and paste emails or upload them from a file.</li>
               <li class="rightColumnListItem"><%= Html.TextArea("ta_bulk", new { style = "width:200px", rows = "8" })%></li>
               <li class="rightColumnListItem"><input type="button" id="al_bulk_delim" value="Add"/><input type="file" id="up_bulk" name="up_bulk" /></li>
           </ul>
       </div>
        <%  if (Model.SelectedRole == "Poll Administrator" && !Model.IsNew)
            { 
                Html.RenderPartial("PollAdministratorGroups", Model); 
            }
        }  %>
        </div>

